<!--

Saherace - Rent a Car

This page shows the login form and the form to register a new customer.
If the login or registration was successful, it forwards to the the
summary page.

-->

<!-- Include the soap client connection and the header area of the website -->
<?php include('includes/header.php'); ?>
	
	<?php
	
	//If login wasn't successful
	if(isset($_GET['login'])) {
		$_SESSION['login'] = $_GET['login'];
		if($_SESSION['login'] == 'false') {
			echo '<div style="color: red;">Kundennummer oder Passwort falsch.</div>';
		}
	}
	
	//if registration wasn't successful
	if(isset($_GET['register'])) {
		$_SESSION['register'] = $_GET['register'];
		if($_SESSION['register'] == 'failed') {
			echo '<div style="color: red;">Registrierung fehlgeschlagen. Bitte versuchen Sie es erneut.</div>';
		}
	}
	
	//If login was successful, forward to summary.php
	if (isset($_SESSION['login'])) {
		if($_SESSION['login'] == 'true') {
			echo '<script>'.
					'window.location.replace("summary.php"); '.
				 '</script>';
			exit;
		}
	}
	?>
	
	
	<!-- Show login form -->
	<form action="summary.php" method="POST">
		<input type="hidden" name="type" value="login"/>
		<input type="hidden" name="login" value="false"/>
		<ul data-role="listview" data-inset="true">
			<li data-role="list-divider">Login</li>
			<li>
				<table>
					<tr>
						<td><label for="customer_id">Kunden-Nr.:</label></td>
						<td><input type="number" id="customer_id" name="customer_id" data-mini="true"/></td>
					</tr>
					<tr>
						<td><label for="customer_pwd">Passwort:</label></td>
						<td><input type="password" id="customer_pwd" name="customer_pwd" data-mini="true"/></td>
					</tr>
				</table>							
			</li>
		</ul>	
		<input type="submit" value="Login" data-icon="arrow-r" data-iconpos="right" />	
	</form>
	
	<!-- Show registration form -->
	<form action="summary.php" method="POST">
		<input type="hidden" id="type" name="type" value="register"/>
		<ul data-role="listview" data-inset="true">
			<li data-role="list-divider">Registrieren</li>
			<li>
				<table>
					<tr>
						<td><label for="register_title">Anrede:</label></td>
						<td>
							<select name="register_title" id="register_title" data-mini="true">
								<option value='Herr'>Herr</option>
								<option value='Frau'>Frau</option>
							</select>
						</td>
					</tr>
					<tr>
						<td><label for="register_name">Name:</label></td>
						<td><input type="text" id="register_name" name="register_name" data-mini="true" required /></td>
					</tr>
					<tr>
						<td><label for="register_surname">Nachname:</label></td>
						<td><input type="text" id="register_surname" name="register_surname" data-mini="true" required /></td>
					</tr>
					<tr>
						<td><label for="register_phone">Telefon:</label></td>
						<td><input type="text" id="register_phone" name="register_phone"  data-mini=true required /></td>
					</tr>
					<tr>
						<td><label for="register_surname">Email:</label></td>
						<td><input type="text" id="register_email" name="register_email"  data-mini=true required /></td>
					</tr>
					<tr>
						<td><label for="register_surname">Geb.-Datum:</label></td>
						<td><input type="date" id="register_birthday" name="register_birthday"  data-mini=true required /></td>
					</tr>
					<tr>
						<td><label for="register_surname">Passwort:</label></td>
						<td><input type="password" id="register_password" name="register_password"  data-mini=true required /></td>
					</tr>
				</table>
			</li>
		</ul>	
		<input type="submit" value="Registrieren" data-icon="arrow-r" data-iconpos="right" />	
	</form>	

<!-- Include the footer area of the website -->
<?php include('includes/footer.php'); ?>
